package com.example.phone.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class SeekAdvancedActivity extends Activity {
	private Spinner positionSpinner;
	private Spinner jobTypeSpinner;
	private Spinner qiyeTypeSpinner;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.seek_advanced_activity);
		positionSpinner = (Spinner) findViewById(R.id.positionSpinner);
		String[] positionItems = { "全部", "解放区", "山阳区", "中站区", "马村区", "修武县",
				"武陟县", "温县", "博爱县", "沁阳市", "孟州市" };
		spinner(positionSpinner, positionItems);
		// ArrayAdapter<String> positionAdapter = new ArrayAdapter<String>(this,
		// android.R.layout.simple_spinner_item, positionItems); //
		// 第二个参数表示spinner没有展开前的UI类型
		jobTypeSpinner = (Spinner) findViewById(R.id.jobType);
		String[] jobTypeItems = { "全部", "物流/仓储/运输类", "包装/印刷类", "技工类", "建筑/工程类",
				"医院/医疗/护理类", "保安/家政服务类", "其他" };
		spinner(jobTypeSpinner, jobTypeItems);
		qiyeTypeSpinner = (Spinner) findViewById(R.id.qiyeTypeSpinner);
		String[] qiyeTypeItems = { "全部", "工业企业", "农业企业", "建筑企业", "交通运输企业",
				"邮电企业", "商业企业", "外贸企业" };
		spinner(qiyeTypeSpinner, qiyeTypeItems);
		// ArrayAdapter<String> jobTypeAdapter = new ArrayAdapter<String>(this,
		// android.R.layout.simple_spinner_item, jobTypeItems);
		// positionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		// positionSpinner.setAdapter(positionAdapter); // 之前已经通过Spinner spin =
		// (Spinner)
		// positionSpinner.setOnItemSelectedListener(listener);
		// positionSpinner.setVisibility(View.VISIBLE);
		// jobTypeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

	}

	private void spinner(Spinner spinner, String[] items) {
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, items);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner.setAdapter(adapter);
		spinner.setOnItemSelectedListener(listener);
		spinner.setVisibility(View.VISIBLE);
	}

	private OnItemSelectedListener listener = new OnItemSelectedListener() {

		@Override
		public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			// TODO Auto-generated method stub

		}

		@Override
		public void onNothingSelected(AdapterView<?> arg0) {
			// TODO Auto-generated method stub

		}
	};

}
